/////////////////////////////////////////////////////////////////////////////
*Appendix Table 2: Gender wage gap in the US: CPS
/////////////////////////////////////////////////////////////////////////////



//Load raw CPS data for 2019 (Note: Download this freely from IPUMS website)
use Data\Raw\cps_raw if year>=2010 & year<=2019, clear

*Recode missing values
replace hourwage = . if hourwage==999.99
replace earnweek = . if earnweek==9999.99
replace uhrswork1 = . if uhrswork1==999 | uhrswork1 == 997

*Keep only those age 25-54
keep if age>=25 & age<=54

*Generate binary employment dependent variable
gen working = (empstat==10|empstat==12)

*Generate hourly wage variable
gen wage = hourwage if !missing(hourwage)
replace wage = earnweek/uhrswork1 if missing(wage)
gen log_wage = log(wage)

*Generate other variables for use in regression
gen age_sq = age*age
gen female = sex-1

//Controls
local nocontrols i.year i.age  i.statefip i.metro 
local controls  `nocontrols' i.educ
local midcontrols `controls'  i.ind i.occ 
local fullcontrols `midcontrols' uhrswork1 i.wkstat i.paidhour i.union 

//Baseline employment regressions

local j=0
local specs 
foreach c in nocontrols controls{
	local j = `j'+1
local dep working
local indep female

	 reg `dep' `indep' ``c''  [aw=earnwt]
	est sto e_e_`j'	//store coefficients
	local specs `specs' e_e_`j'
}
	
//Baseline wage regressions
foreach c in nocontrols controls midcontrols fullcontrols{
	local j = `j'+1
local dep log_wage
local indep female

	 reg `dep' `indep' ``c''  [aw=earnwt]
	est sto e_w_`j'	
	local specs `specs' e_w_`j'					//store coefficients

}
	

//Appendix Table 2
esttab  `specs' using Tables\AppendixTable2.rtf, se keep(female) label replace
